// pages/start-merchant/index.js
Page({
  /**
   * 页面的初始数据
   */
  data: {
    list: [],
    type: "",
  },

  getData() {
    const { type } = this.data;

    const params = {
      type,
    };

    wx.ajax
      .post(
        type === "7"
          ? "queryUserSubscribeMerchant.action"
          : "queryMyMerchant.action",
        params,
        true
      )
      .then((res) => {
        if (res.success) {
          this.setData({
            list: res.result || [],
          });
        }
      });
  },

  handleToTechnologyIntegral(event) {
    const { id } = event.currentTarget.dataset;

    wx.navigateTo({
      // url: "/pages/technology-integral/technology-integral?&store_id=" + id,
      url: `/credits/pages/technology-integral/index?storeId=${id}`
    });
  },

  handleToPressureTest(event) {
    const { type } = this.data;
    const { id } = event.currentTarget.dataset;

    wx.navigateTo({
      url: "/pages/pressure-test-list/index?&type=" + type + "&id=" + id,
    });
  },

  handleToInstall() {
    wx.navigateTo({
      url: "/pages/install-report-scan/index?type=" + this.data.type,
    });
  },

  handleToOrder(event) {
    wx.navigateTo({
      url:
        "/pages/purchase-out-order/index?type=" +
        this.data.type +
        "&id=" +
        event.currentTarget.dataset.id +
        "&from=0",
    });
  },

  handleToProCenter(event) {
    wx.navigateTo({
      url:
        "/pages/product-center-page/product-center?merchant_id=" +
        event.currentTarget.dataset.id,
    });
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      type: options.type,
    });

    wx.setNavigationBarTitle({
      title: options.title,
    });

    this.getData();
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {},

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {},

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {},

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {},

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {},

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {},

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {},
});
